package jtracking_server;

import java.io.IOException;
import java.util.Calendar;
import org.apache.log4j.*;

// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
// #[regen=yes,id=DCE.F70FC9F2-1E7F-C612-F099-26DAD26B855B]
// </editor-fold> 
public class Main {

    protected static Main main;
    private FileAppender appenderAll = null;
    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.AF0365F0-A452-1465-ECE2-DD7B85BDFDD0]
    // </editor-fold> 
    protected Datenempfänger datenempfänger;

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.F3BADB38-915E-4E95-5884-702E1B760E9E]
    // </editor-fold> 
    protected TrayGUI trayGUI;

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.9B5C426A-139D-83E0-195F-36322A5C2504]
    // </editor-fold> 
    protected UebersichtsGUI gui;

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.048C70BD-EA0B-8B7F-8A08-B3B07859344A]
    // </editor-fold> 
    protected DBManager dBManager;

    protected LoggerGUI loggerGUI;

    final String logDatei = "../../jTracking-log-All.txt";

    // <editor-fold defaultstate="collapsed" desc=" UML Marker ">
    // #[regen=yes,id=DCE.146246A1-7738-A2BB-6B71-40162B38FC74]
    // </editor-fold> 
    protected Main () {
        main=this;
        //Loggingsystem initialisieren
        PatternLayout layout = new PatternLayout("%-6d{dd.MM.yy HH:mm:ss,SSS} [%17.17t] %-5p %30.30c %x - %m%n");
        try {
            appenderAll = new FileAppender(layout,logDatei,true);
        } catch(Exception e) {
            System.err.println("Logger-All konnte nicht initialisiert werden!");
        }
        appenderAll.setThreshold(Level.ALL);

        Logger.getRootLogger().addAppender(appenderAll);

        //Konsolen-Ausgabe

        ConsoleAppender a = new ConsoleAppender(layout);
        a.setThreshold(Level.ALL);
        Logger.getRootLogger().addAppender(a);

        //lets test this
        Logger l = Logger.getLogger(this.getClass());
        l.info("JTracking gestartet am "+Calendar.getInstance().getTime());



        //objekte erzeugen und ggf Threads starten.
        dBManager = new DBManager();
        datenempfänger = new Datenempfänger(58722);
        datenempfänger.start();
        trayGUI = new TrayGUI(this);
        
        //gui = new GUI_n(dBManager); //diese beiden müssen von traygui aufgerufen werden.
        //gui.setVisible(true);

        //Ist die Main-Klasse hiermit fertig?

        
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.6146AFB3-6203-9066-CC81-7F792815AF2A]
    // </editor-fold> 


   public static void main(String args[]) {
      main = new Main();
      
   }
}





